import {createStore} from 'vuex'
import {login} from "api";
import {ElMessage} from "element-plus";

const store = createStore({
    state: {
        // 用户的token
        token: '',
        // 用户登录信息
        userLoginInfo: {},
        // 当前路由信息
        currentRouterInfo:{},
        // ue4传输的数据
        ue4ToData:{},
        // 屏幕的宽高
        screenWH:{},
        // echarts实例集合
        refreshEcharts:{},
    },
    getters: {},
    mutations: {},
    actions: {
        /**
         * @author: 王琛
         * @description: 退出登录
         * @Date: 2021-11-17 09:49:02
         * @param {*}
         * @return {*}
         */
        logOut({state}, parameter) {
            login.logOut().then((data) => {
                if (data.code == 0) {
                    if (state.token) ElMessage.success("退出成功")
                    // 清空数据
                    state.token = "";
                    state.userLoginInfo = "";
                    sessionStorage.removeItem("daxing_Airport_userLoginInfo");
                    sessionStorage.removeItem("daxing_Airport_token");
                } else {
                    if (parameter) ElMessage.warning("退出失败")
                }
            })
        }
    },
    modules: {}
})
export default store